package index.oop;

import java.util.Random;
import java.util.Scanner;

public class review {
    public static void main(String[] args) {
        //1.数组 random  scanner
        //1.数组
        //定义数组
        //静态初始化
        String []arr=new String[]{"apple","pear"};
        int []arr3=new int[]{1,2,34,5};

        //简写
        //数组遍历
        //1 for
        for (int i = 0; i <=arr.length-1 ; i++) {
            System.out.println(arr[i]);
        }
        //2 foreach
        for (String item:arr) {
            System.out.println(item);
        }
        String []arr1={"a","b"};
        //动态初始化
        int []arr2=new int[2];
        arr2[0]=2;
        arr2[1]=3;
        System.out.println(arr2[0]);
        System.out.println(arr2[1]);

//1.random
        Random rad=new Random();//创造了随机数对象
        //[0,10) +1->[1,10]

        for (int i = 0; i <10 ; i++) {
            System.out.println(rad.nextInt(0,10));
        }
//2.scanner
//        Scanner sc=new Scanner(System.in);
//        System.out.println("请输入你的数字");
//        System.out.println( sc.nextInt()%2==0?"evenNumber":"not evenNumber");

        //2.值和传递  方法
        //基本数据类型  存在于栈空间  真实的值


        //引用数据类型  存在于堆内存中  引用其他空间的地址
        int a=1;
        int []arr4=new int[]{1,2,3};
        int b=a;
        b=3;
        System.out.println(a);
        int []arr5=arr4;
        arr5[0]=3;
        System.out.println(arr4[0]);

        //3.构造类   创造一个对象
        int []methodOfTest=new int[]{1,2,3};
        method(methodOfTest);
        double[]arr6=new double[0];
        for (double i :copyArr(arr6)) {
            System.out.println(i);
        }
        for (int i = 0; i <=copyArr(arr6).length-1 ; i++) {
            System.out.println(copyArr(arr6)[i]);
        }
        System.out.println(copyArr(arr6)[0]);
//        int [] qwe={1,212};
//        System.out.println(qwe[2]);
//
//        double []arr7=copyArr(arr6);
//        for (double i:arr7) {
//            System.out.println(arr7[(int) i]);
//        }
    }
    public  static  void method(int []arr){
        for (int i = 0; i <arr.length ; i++) {
            System.out.println(arr[i]);
        }
        for(int item :arr){
            System.out.println(item);
        }
        System.out.println(Arr1());
    }
    public static int[] Arr1(){
        int []arr=new int[]{1,2,3};
        for (int i = 0; i < arr.length; i++) {
//            return new int[]{arr[i]};
            System.out.println(arr[i]);
        }
       return arr;
    }
    public  static  double[] copyArr(double []arr){
        double []arr1=new double[] {12.0,212,12,121};
        arr=arr1;
//        for (int i : arr) {
//            System.out.println(i);
//        }
        return arr;
    }
}
